package com.zrgj.manager.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.zrgj.common.response.BaseResponse;
import com.zrgj.common.response.StatusCodeEnum;
import com.zrgj.domain.Order;
import com.zrgj.manager.service.IOrderService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping(value = "/admin")
public class OrderController {
    @Reference
    private IOrderService orderService;

    /**
     * 获取订单列表
     * @return
     */
    @RequestMapping(value = "/getOrderList")
    public BaseResponse getOrderList(){
        List<Order> select = orderService.select();
        return new BaseResponse(StatusCodeEnum.SUCCESS,select);
    }

    /**
     * 发货
     * @param orderId
     * @return
     */
    @RequestMapping(value = "/send")
    public BaseResponse send(String orderId){
        Order order = orderService.findById(orderId);
        order.setStateId(3);
        orderService.update(order);
        return new BaseResponse(StatusCodeEnum.SUCCESS);
    }
}
